package poo.varie;

import java.awt.BorderLayout;

import javax.swing.DefaultListModel;
import javax.swing.JPanel;
import javax.swing.JFrame;
import javax.swing.JButton;
import java.awt.Rectangle;
import javax.swing.JScrollPane;
import javax.swing.JList;
import java.awt.Dimension;
import javax.swing.JTextField;

public class List extends JFrame {

	private static final long serialVersionUID = 1L;
	private JPanel jContentPane = null;
	private JButton jButton = null;
	private JScrollPane jScrollPane = null;
	private JList jList = null;
	private JTextField jTextField = null;
	private DefaultListModel listModel;

	public List() {
		super();
		listModel = new DefaultListModel();
		initialize();
	}

	private void initialize() {
		this.setSize(300, 232);
		this.setContentPane(getJContentPane());
		this.setTitle("JFrame");
		this.setVisible(true);
	}

	private JPanel getJContentPane() {
		if (jContentPane == null) {
			jContentPane = new JPanel();
			jContentPane.setLayout(null);
			jContentPane.add(getJButton(), null);
			jContentPane.add(getJScrollPane(), null);
			jContentPane.add(getJTextField(), null);
		}
		return jContentPane;
	}

	private JButton getJButton() {
		if (jButton == null) {
			jButton = new JButton();
			jButton.setBounds(new Rectangle(63, 148, 162, 37));
			jButton.addActionListener(new java.awt.event.ActionListener() {
				public void actionPerformed(java.awt.event.ActionEvent e) {
					listModel.addElement(jTextField.getText());
				}
			});
		}
		return jButton;
	}

	private JScrollPane getJScrollPane() {
		if (jScrollPane == null) {
			jScrollPane = new JScrollPane();
			jScrollPane.setBounds(new Rectangle(62, 46, 165, 92));
			jScrollPane.setViewportView(getJList());
		}
		return jScrollPane;
	}

	private JList getJList() {
		if (jList == null) {
			jList = new JList();
			jList.setModel(listModel);
			jList.setVisibleRowCount(-1);
		}
		return jList;
	}

	private JTextField getJTextField() {
		if (jTextField == null) {
			jTextField = new JTextField();
			jTextField.setBounds(new Rectangle(62, 4, 164, 33));
		}
		return jTextField;
	}

	public static void main(String args[]) {
		new List();
	}

}